<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>搜索</title>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css" />
    <style type="text/css">
        body {
            background: #fff;
            line-height: 0!important;
            margin: 0;
            padding: 0;
        }

        .wrap {
            width: 100%!important;
            display: flex!important;
            border: none;
            background-size: 100% 1px;
            background-repeat: no-repeat;
            background-position: bottom;
            background-image: linear-gradient(0, #EEEEEE, #EEEEEE 50%, transparent 50%);
            background-image: -webkit-linear-gradient(90deg, #EEEEEE, #EEEEEE 50%, transparent 50%);
            padding: 6px 15px;
            box-sizing: border-box;
        }

        .header_left {
            width: 100%;
            height: 32px;
            display: flex;
            background: #F4F4F4;
            border-radius: 17px;
            flex: 1;
        }

        .header_left .search_icon {
            width: 14px;
            height: 14px;
            margin-top: 9px;
            margin-left: 10px;
        }

        .header_left .search_input {
            width: 100%;
            height: 20px;
            margin-top: 6px;
            margin-left: 5px;
            margin-right: 10px;
            flex: 1;
        }

        .header_left .search_input input {
            height: 100%;
            font-size: 14px;
        }

        .header_right {
            width: auto;
            height: 22px;
            margin-top: 5px;
            margin-left: 15px;
        }

        .header_right img {
            width: 22px;
            height: 22px;
            display: block;
        }

        .header_right span {
            display: block;
            font-size: 16px;
            line-height: 22px;
            white-space: nowrap;
        }

        .clear_icon {
            width: 16px;
            height: 16px;
            background: url(../../image/remove.png) no-repeat;
            background-size: 100% 100%;
            margin-top: 8px;
            /*flex: 1;*/
            margin-right: 10px;
        }

        .tablist {
            width: 100%;
            padding: 0 15px;
            overflow: hidden;
            box-sizing: border-box;
        }

        .nav {
            display: -webkit-box;
            display: -webkit-flex;
            display: flex;
            align-items: center;
            background: #fff;
            height: 40px;
        }

        .nav .nav-menu {
            width: auto;
            height: 100%;
            margin-left: 30px;
            /*flex: 1;*/
            font-size: 13px;
            color: #FFFFFF;
            letter-spacing: 0;
            text-align: center;
            /* padding-top: 10px; */
            position: relative;
        }

        .nav .nav-menu:first-child {
            margin-left: 0;
        }

        .nav .nav-menu span {
            width: auto;
            display: block;
        }

        .nav .nav-menu span:first-child {
            height: 20px;
            line-height: 20px;
            margin-top: 10px;
            color: #666666;
            font-size: 15px;
        }

        .nav .nav-menu span.selected {
            font-size: 15px;
            font-weight: bold;
            color: #333333;
        }

        .nav .nav-menu span.selected_line {
            width: 100%;
            height: 2px;
            background: #db0a17;
            margin: 0 auto;
            /* margin-top: 7px; */
            border-radius: 2.5px;
            position: absolute;
            bottom: 4px;
        }
    </style>
</head>

<body id="header">
    <div class="" id="app">
        <header class="wrap">
            <div class="header_right" style="margin-left: 0;" @click='closePage()'>
                <img src="../../image/back_arrow.png" alt="">
            </div>
            <div class="header_left">
                <div class="search_icon">
                    <img src="../../image/search.png" alt="">
                </div>
                <div class="search_input">
                    <form action="javascript:return true" style="display:block;height:20px;">
                        <input type="search" placeholder="输入商品或粘贴宝贝标题搜索" @input='changeValue()' @keyup.13="searchContent(0)" v-model='keyword'>
                    </form>
                </div>
                <div class="clear_icon" v-if='keyword' @click='clearKeyword()'></div>
            </div>
            <div class="header_right">
                <span tapmode @click="searchContent(0)">搜索</span>
            </div>
        </header>
        <div class="tablist">
            <div class="nav" id="nav">
                <div class="nav-menu" v-for='(item,index) in infolist' @click="fnhandleclick(index)">
                    <span :class="{'selected':isActive==index}">{{item}}</span>
                    <span :class="{'selected_line':isActive==index}"></span>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/cling.js"></script>
<script type="text/javascript">
    apiready = function() {
        var header = $api.byId('header');
        $api.fixStatusBar($api.byId('header'));
        vm.initListPage();
        api.addEventListener({
            name: 'searchEvent'
        }, function(ret, err) {
            if (ret) {
                vm.keyword = ret.value.keyWord;
            }
        });
        if (api.pageParam.keyWord) {
            vm.keyword = api.pageParam.keyWord;
        }
        console.log($api.getStorage('appinfo').iosExamine);
        if($api.getStorage('appinfo').iosExamine=="true"){
           vm.infolist = ['淘宝']
        }else{
          // alert(222)
           vm.infolist = ['淘宝', '京东', '拼多多']
        }
    }

    var vm = new Vue({
        el: '#app',
        data: {
            isActive:0,
            infolist:[],
            keyword:''
        },
        methods: {
            initListPage: function(keyword) {
                var headerH = $api.offset($api.byId('header')).h;
                api.openFrameGroup({
                    name: 'listFrameGroup',
                    background: '#FAF9F9',
                    scrollEnabled: false,
                    rect: {
                        marginTop: headerH,
                        marginBottom: api.safeArea.bottom, // main页面距离win底部的高度
                        w: 'auto'
                    },
                    index:0,
                    preload:3,
                    frames: [{
                        name: 'tb_order_frame',
                        url: './tb_order_frame.html',
                        bgColor: '#FAF9F9',
                        bounces: true,
                        pageParam: {
                            keyword: api.pageParam.keyWord
                        }
                    }, {
                        name: 'jd_order_frame',
                        url: './jd_order_frame.html',
                        bgColor: '#FAF9F9',
                        bounces: true,
                        pageParam: {
                            keyword: keyword
                        }

                    }, {
                        name: 'pdd_order_frame',
                        url: './pdd_order_frame.html',
                        bgColor: '#FAF9F9',
                        bounces: true,
                        pageParam: {
                            keyword: keyword
                        }
                    }]
                }, function(ret, err) {});
            },
            fnhandleclick: function(idx) {
                vm.isActive = idx;
                if(vm.keyword){
                   vm.searchContent(idx);
                }

                api.setFrameGroupIndex({
                    name: 'listFrameGroup',
                    index: idx,
                    scroll: true
                });
            },
            openSearchPage: function(keyword) {
                var headerH = $api.offset($api.byId('header')).h;
                api.openFrame({
                    name: 'search_keyword_list_frame',
                    url: './search_keyword_list_frame.html',
                    rect: {
                        x: 0,
                        y: headerH - 40,
                        w: 'auto',
                        h: 'auto'
                    },
                    bounces:true,
                    bgColor:"#FAF9F9",
                    vScrollBarEnabled:true,
                    hScrollBarEnabled:true,
                    pageParam: {
                        keyword: keyword
                    }
                });
            },
            changeValue: function() {
                if (vm.keyword.length != 0) {
                    vm.openSearchPage(vm.keyword);
                } else {
                    cl.closeFrame({
                        name: 'search_keyword_list_frame'
                    })
                }
            },
            clearKeyword: function() {
                vm.keyword = '';
                cl.closeFrame({
                    name: 'search_keyword_list_frame'
                })
            },
            closePage: function() {
                cl.closeWin({
                    name: 'search'
                })
            },
            searchContent: function(i) {

                if (i == 0) {
                    if (!vm.keyword) {
                        cl.toast({
                            msg: '请输入商品名称或宝贝标题'
                        });
                        return
                    }
                    cl.closeFrame({
                        name: 'search_keyword_list_frame'
                    })
                    api.setFrameGroupIndex({
                        name: 'listFrameGroup',
                        index: i,
                        scroll: true
                    });
                    vm.isActive = i;
                    var jsfun1 = 'vm.clearData()';
                    api.execScript({
                        frameName: 'tb_order_frame',
                        script: jsfun1
                    });
                    var jsfun = 'vm.searchContent("' + vm.keyword + '");';
                    api.execScript({
                        frameName: 'tb_order_frame',
                        script: jsfun
                    });
                }
                if (i == 1) {
                    if (!vm.keyword) {
                        cl.toast({
                            msg: '请输入商品名称或宝贝标题'
                        });
                        return
                    }
                    cl.closeFrame({
                        name: 'search_keyword_list_frame'
                    })
                    var jsfun1 = 'vm.clearData()';
                    api.execScript({
                        frameName: 'jd_order_frame',
                        script: jsfun1
                    });
                    var jsfun = 'vm.searchContent("' + vm.keyword + '");';
                    api.execScript({
                        frameName: 'jd_order_frame',
                        script: jsfun
                    });
                }
                if (i == 2) {
                    if (!vm.keyword) {
                        cl.toast({
                            msg: '请输入商品名称或宝贝标题'
                        });
                        return
                    }
                    cl.closeFrame({
                        name: 'search_keyword_list_frame'
                    })
                    var jsfun1 = 'vm.clearData()';
                    api.execScript({
                        frameName: 'pdd_order_frame',
                        script: jsfun1
                    });
                    var jsfun = 'vm.searchContent("' + vm.keyword + '");';
                    api.execScript({
                        frameName: 'pdd_order_frame',
                        script: jsfun
                    });
                }
            }
        }
    })
</script>

</html>
